
---------- BMD.BAS
Attribute VB_Name = "BMD"
' Constants, enums, and other goodies used with the BMD data import/sifting processes.
' used with IBMDShipToException to determine which type of exception it is.
Public Enum BMDImportExceptionType
    BMDEXCEPTION_CRITICAL = 0
    BMDEXCEPTION_VALIDATION = 1
    BMDEXCEPTION_MATCHROOT = 2
    BMDEXCEPTION_MATCHSTORE = 3
    BMDEXCEPTION_MATCHSHIPTO = 4
    BMDEXCEPTION_MATCHPRODUCT = 5
'include or exclude the Boise Cascade BMD - Locations data.
Public Const BMD_DistributorRegionID As Long = 4&

---------- SATRACKFORM.BAS
Public Sub LoadBMDBatchCombo(ByRef ctrl As Control, Optional ByVal GridColumn As Long = -1)
    & "FROM BMDBatch AS b ORDER BY b.CreatedDate DESC"

---------- SATRACKMAIN.BAS
    ERR_BAD_BMD_DISTRO_ID = vbObjectError + 512 + 5001
    cnBMD_ALL = &H0&                    'All customers
    'cnBMD_EXCLUDED = &H1&              'All except BMD
    OPTION_EXCLUDE_BMD = &H1&           'All except BMD
    'cnBMD_ONLY = -1                    'Only BMD
    OPTION_BMD_ONLY = &H2&              'Only BMD
    DEP_BMDShipTo = &H80

---------- APPSETTING NO REGISTRY.CLS
Public Property Get BMDDistroID() As Long
Dim sBMDID As String
    sBMDID = reg.GetValue("BMDDistroID")
    If IsNumeric(sBMDID) Then
        BMDDistroID = CLng(sBMDID)
        BMDDistroID = 0
    Err.Raise Err.Number, "[clsAppSetting_BMDDistroID]" & Err.Source, Err.Description
Public Property Let BMDDistroID(ByVal l As Long)
    GetReg().SetValue "BMDDistroID", CStr(l)
    Err.Raise Err.Number, "[clsAppSetting_BMDDistroID]" & Err.Source, Err.Description

---------- APPSETTING.CLS
Public Property Get BMDDistroID() As Long
Dim sBMDID As String
    'sBMDID = GetReg.GetValue("BMDDistroID")
    sBMDID = GetSetting(REGKEY_APP_NAME, REGKEY_SECTION, "BMDDistroID")
    If IsNumeric(sBMDID) Then
        BMDDistroID = CLng(sBMDID)
        BMDDistroID = 0
    Err.Raise Err.Number, "[clsAppSetting_BMDDistroID]" & Err.Source, Err.Description
Public Property Let BMDDistroID(ByVal l As Long)
    'GetReg.SetValue "BMDDistroID", CStr(l)
    SaveSetting REGKEY_APP_NAME, REGKEY_SECTION, "BMDDistroID", CStr(l)
    Err.Raise Err.Number, "[clsAppSetting_BMDDistroID]" & Err.Source, Err.Description

---------- BMDBATCH.CLS
Attribute VB_Name = "clsBMDBatch"
'*** Table: BMDBatch
    Err.Raise Err.Number, Err.source, "[BMDBatch.Clear]" & Err.Description
        s = "exec BMDBatchAddRow " _
    Err.Raise Err.Number, "[BMDBatch.AddRow]" & Err.source, Err.Description
        s = "exec BMDBatchUpdateRow " _
    Err.Raise Err.Number, "[BMDBatch.UpdateRow]" & Err.source, Err.Description
    Err.Raise Err.Number, "[BMDBatch.PopulateFromRow]" & Err.source, Err.Description

---------- BMDEXCEPTIONCRITICAL.CLS
Attribute VB_Name = "clsBMDExceptionCritical"
'  Exception generated by the BMD ShipTo Import process:
Implements IBMDException
Private Property Get IBMDException_ExceptionType() As BMDImportExceptionType
    IBMDException_ExceptionType = BMDEXCEPTION_CRITICAL
Private Property Get IBMDException_ExceptionTypeString() As String
    IBMDException_ExceptionTypeString = "Critical"
Private Property Get IBMDException_Message() As String
    IBMDException_Message = sMsg
Private Property Let IBMDException_Message(RHS As String)
Private Property Let IBMDException_RowID(RHS As Long)
Private Property Get IBMDException_RowID() As Long
    IBMDException_RowID = RowID

---------- BMDEXCEPTIONMATCHPRODUCT.CLS
Attribute VB_Name = "clsBMDExceptionMatchProduct"
'  Exception generated by the BMD Sales Import process:
'   Can't find a BMDProduct to match to,
Implements IBMDException
Private oBMDSales As clsBMDSales
Public Property Get bmdSales() As clsBMDSales
    Set bmdSales = oBMDSales
Public Property Set bmdSales(o As clsBMDSales)
    Set oBMDSales = o
Private Property Get IBMDException_ExceptionType() As BMDImportExceptionType
    IBMDException_ExceptionType = BMDEXCEPTION_MATCHPRODUCT
Private Property Get IBMDException_ExceptionTypeString() As String
    IBMDException_ExceptionTypeString = "Product Match"
Private Property Get IBMDException_Message() As String
    IBMDException_Message = sMsg
Private Property Let IBMDException_Message(RHS As String)
Private Property Let IBMDException_RowID(RHS As Long)
Private Property Get IBMDException_RowID() As Long
    IBMDException_RowID = RowID

---------- BMDEXCEPTIONMATCHROOT.CLS
Attribute VB_Name = "clsBMDExceptionMatchRoot"
'  Exception generated by the BMD ShipTo Import process:
Implements IBMDException
Private oBMDShipTo As clsBMDShipTo
Public Property Get bmdShipTo() As clsBMDShipTo
    Set bmdShipTo = oBMDShipTo
Public Property Set bmdShipTo(o As clsBMDShipTo)
    Set oBMDShipTo = o
Private Property Get IBMDException_ExceptionType() As BMDImportExceptionType
    IBMDException_ExceptionType = BMDEXCEPTION_MATCHROOT
Private Property Get IBMDException_ExceptionTypeString() As String
    IBMDException_ExceptionTypeString = "Root Match"
Private Property Get IBMDException_Message() As String
    IBMDException_Message = sMsg
Private Property Let IBMDException_Message(RHS As String)
Private Property Let IBMDException_RowID(RHS As Long)
Private Property Get IBMDException_RowID() As Long
    IBMDException_RowID = RowID

---------- BMDEXCEPTIONMATCHSHIPTO.CLS
Attribute VB_Name = "clsBMDExceptionMatchShipto"
'  Exception generated by the BMD Sales Import process:
'   Can't find a BMDShipto to match for this ShipTo,
Implements IBMDException
Private oBMDSales As clsBMDSales
Public Property Get bmdSales() As clsBMDSales
    Set bmdSales = oBMDSales
Public Property Set bmdSales(o As clsBMDSales)
    Set oBMDSales = o
Private Property Get IBMDException_ExceptionType() As BMDImportExceptionType
    IBMDException_ExceptionType = BMDEXCEPTION_MATCHSHIPTO
Private Property Get IBMDException_ExceptionTypeString() As String
    IBMDException_ExceptionTypeString = "Shipto Match"
Private Property Get IBMDException_Message() As String
    IBMDException_Message = sMsg
Private Property Let IBMDException_Message(RHS As String)
Private Property Let IBMDException_RowID(RHS As Long)
Private Property Get IBMDException_RowID() As Long
    IBMDException_RowID = RowID

---------- BMDEXCEPTIONMATCHSTORE.CLS
Attribute VB_Name = "clsBMDExceptionMatchStore"
'  Exception generated by the BMD ShipTo Import process:
Implements IBMDException
Private oBMDShipTo As clsBMDShipTo
Public Property Get bmdShipTo() As clsBMDShipTo
    Set bmdShipTo = oBMDShipTo
Public Property Set bmdShipTo(o As clsBMDShipTo)
    Set oBMDShipTo = o
Private Property Get IBMDException_ExceptionType() As BMDImportExceptionType
    IBMDException_ExceptionType = BMDEXCEPTION_MATCHSTORE
Private Property Get IBMDException_ExceptionTypeString() As String
    IBMDException_ExceptionTypeString = "Store Match"
Private Property Get IBMDException_Message() As String
    IBMDException_Message = sMsg
Private Property Let IBMDException_Message(RHS As String)
Private Property Let IBMDException_RowID(RHS As Long)
Private Property Get IBMDException_RowID() As Long
    IBMDException_RowID = RowID

---------- BMDEXCEPTIONVALIDATE.CLS
Attribute VB_Name = "clsBMDExceptionValidate"
'  Exception generated by the BMD ShipTo Import process:
Implements IBMDException
Private Property Get IBMDException_ExceptionType() As BMDImportExceptionType
    IBMDException_ExceptionType = BMDEXCEPTION_VALIDATION
Private Property Get IBMDException_ExceptionTypeString() As String
    IBMDException_ExceptionTypeString = "Validation"
Private Property Get IBMDException_Message() As String
    IBMDException_Message = sMsg
Private Property Let IBMDException_Message(RHS As String)
Private Property Let IBMDException_RowID(RHS As Long)
Private Property Get IBMDException_RowID() As Long
    IBMDException_RowID = RowID

---------- BMDPRODUCT.CLS
Attribute VB_Name = "clsBMDProduct"
'*** Table: BMDProduct
Private mBMDProductDesc As String
Public Property Let BMDProductDesc(ByVal vData As String)
    mBMDProductDesc = vData
Public Property Get BMDProductDesc() As String
    BMDProductDesc = mBMDProductDesc
    mBMDProductDesc = ""
    Err.Raise Err.Number, Err.Source, "[BMDProduct.Clear]" & Err.Description
    Err.Raise Err.Number, "[BMDProduct.AddRow]" & Err.Source, Err.Description
    s = "exec BMDProductAddRow " _
        & oUtil.SQLFormatChar(mBMDProductDesc, False) & "," _
    Err.Raise Err.Number, "[BMDProduct.UpdateRow]" & Err.Source, Err.Description
    oDBRun.ExecSQL "exec BMDProductDeleteRow " & mMajorMinorID
        mBMDProductDesc = .Item("BMDProductDesc")
    Err.Raise Err.Number, "[BMDProduct.PopulateFromRow]" & Err.Source, Err.Description

---------- BMDPRODUCTIMPORT.CLS
Attribute VB_Name = "clsBMDProductImport"
' the existing BMDProducts in the database, for duplicate-checking
Private rsBMDProduct As Recordset
    ' retrieve the current BMD Products so we don't load any duplicates
    Set rsBMDProduct = gDBAccess.GetAllBMDProduct
Dim bmdprod As clsBMDProduct
                Set bmdprod = gDBAccess.CreateBMDProduct
                bmdprod.MajorMinorID = .Cells(, COL_MAJORMINOR)
                bmdprod.BMDProductDesc = .Cells(, COL_PRODUCTDESC)
                bmdprod.ProductTypeID = Null
                bmdprod.UpdateRow
    With rsBMDProduct
    Err.Raise Err.Number, "[clsBMDProductImport.AddErrorMsg]" & Err.Source, Err.Description

---------- BMDSALES.CLS
Attribute VB_Name = "clsBMDSales"
'*** Table: BMDSales
Private mBMDSalesID As Long
Private mBMDShipToID As Long
Private mBMDProductDesc As String
Public Property Let BMDSalesID(ByVal vData As Long)
    mBMDSalesID = vData
Public Property Get BMDSalesID() As Long
    BMDSalesID = mBMDSalesID
Public Property Let BMDShipToID(ByVal vData As Long)
    mBMDShipToID = vData
Public Property Get BMDShipToID() As Long
    BMDShipToID = mBMDShipToID
Public Property Let BMDProductDesc(ByVal v As String)
    mBMDProductDesc = v
Public Property Get BMDProductDesc() As String
    BMDProductDesc = mBMDProductDesc
    mBMDSalesID = 0
    mBMDShipToID = 0
    mBMDProductDesc = vbNullString
    Err.Raise Err.Number, Err.source, "[BMDSales.Clear]" & Err.Description
    If mBMDSalesID > 0 Then
        AddRow = mBMDSalesID
        s = "exec BMDSalesAddRow " _
            & oUtil.SQLFormatNumber(mBMDShipToID, False) & "," _
        mBMDSalesID = lResult
    Err.Raise Err.Number, "[BMDSales.AddRow]" & Err.source, Err.Description
    If mBMDSalesID = 0 Then
        s = "exec BMDSalesUpdateRow " _
            & oUtil.SQLFormatNumber(mBMDSalesID, False) & "," _
            & oUtil.SQLFormatNumber(mBMDShipToID, False) & "," _
    Err.Raise Err.Number, "[BMDSales.UpdateRow]" & Err.source, Err.Description
    oDBRun.ExecSQL "exec BMDSalesDeleteRow " & mBMDSalesID
        mBMDSalesID = .Item("BMDSalesID")
        mBMDShipToID = .Item("BMDShipToID")
    Err.Raise Err.Number, "[BMDSales.PopulateFromRow]" & Err.source, Err.Description

---------- BMDSALESIMPORT.CLS
Attribute VB_Name = "clsBMDSalesImport"
'Private Const COL_PRODUCTSIZE As Integer = 10      ' removed from BMD Sales as given to kay, renumbered down:
Private Const BMDSALES_ROWSTART As Integer = 2
Private rsBMDProducts As Recordset
Private colBMDSales As Collection ' a collection of complete and incomplete ShipTo objects
Private curbatch As clsBMDBatch
' THE BMD IMPORT MANIFESTO
'    - Complete: BMDSales record matched to both Retailer AND Product
'    - Accurate: the Retailer Name "appears" to match the BMD ShipTo Name.
Public Property Get BMDSalesCollection() As Collection
    Set BMDSalesCollection = colBMDSales
Public Property Get BatchDetails() As clsBMDBatch
Dim oCrit As clsBMDExceptionCritical
    Set oCrit = New clsBMDExceptionCritical
Dim o As clsBMDExceptionCritical
    Set o = New clsBMDExceptionCritical
Private Sub AddException_MatchProduct(sMsg As String, RowID As Long, bmdSales As clsBMDSales)
Dim o As clsBMDExceptionMatchProduct
    Set o = New clsBMDExceptionMatchProduct
    Set o.bmdSales = bmdSales
    Err.Raise Err.Number, "[clsBMDSalesImport_AddException_MatchProduct]" & Err.Source, Err.Description
Private Sub AddException_MatchShipTo(sMsg As String, RowID As Long, bmdSales As clsBMDSales)
Dim o As clsBMDExceptionMatchShipto
    Set o = New clsBMDExceptionMatchShipto
    Set o.bmdSales = bmdSales
    Err.Raise Err.Number, "[clsBMDSalesImport_AddException_MatchShipto]" & Err.Source, Err.Description
    Set rsBMDProducts = gDBAccess.GetAllBMDProduct
        MsgBox "This Workbook has already been imported.  To avoid creating duplicate sales records, it cannot be imported again.", vbOKOnly + vbInformation, "Can't re-import BMD Spreadsheets"
        Set curbatch = gDBAccess.CreateBMDBatch(sXLFile)
        'row in case BMD changes their query.
        lStartingRow = BMDSALES_ROWSTART
    Err.Raise Err.Number, "[clsBMDSalesImport_alreadyImported]" & Err.Source, Err.Description
Dim bmdSales As clsBMDSales
        ' 2. can we match to a BMDShipTo record?
        ' 3. can we match to a BMDProduct record?
        Set bmdSales = gDBAccess.CreateBMDSales
        bmdSales.BMDShipToID = GetBMDShipToID(.Cells(, COL_WAREHOUSE), _
        ' fill in the rest of the BMDSales fields
        bmdSales.ImportShipToID = .Cells(, COL_SHIPTOID)
        bmdSales.ActivityDate = .Cells(, COL_ACTIVITYDATE)
        bmdSales.Warehouse = .Cells(, COL_WAREHOUSE)  ' WAREHOUSE is termed 'Branch' in other BMD documents.
        bmdSales.Customer = .Cells(, COL_CUSTOMER)
        'bmdSales.ProductSize = .Cells(, COL_PRODUCTSIZE)
        bmdSales.ProductDesc = .Cells(, COL_PRODUCTDESC)
        bmdSales.SalesAmt = .Cells(, COL_SALESAMT)
        bmdSales.ShiptoName = .Cells(, COL_SHIPTONAME)
        bmdSales.ShipToCity = .Cells(, COL_SHIPTOCITY)
        bmdSales.ShipToState = .Cells(, COL_SHIPTOSTATE)
        bmdSales.BatchID = curbatch.BatchID
        bmdSales.BMDProductDesc = .Cells(, COL_PRODUCTDESC)
        If bmdSales.BMDShipToID < 1 Then
            ' couldn't match BMDShipTo record
            AddException_MatchShipTo "Couldn't match ShipTo", rngRow.row, bmdSales
        bmdSales.MajorMinorID = .Cells(, COL_MAJORMINORID)
        If Not VerifyBMDProductID(bmdSales.MajorMinorID) Then
                AddException_MatchProduct "Couldn't match Product", rngRow.row, bmdSales
        bmdSales.AddRow
        curbatch.TotalSales = curbatch.TotalSales + bmdSales.SalesAmt
        colBMDSales.Add bmdSales, FW_COLLECTION_KEY & bmdSales.BMDSalesID
    Err.Raise Err.Number, "[clsBMDShipToImport.IsRowBlank]" & Err.Source, Err.Description
Private Function GetBMDShipToID(Branch As String, ShipToID As Long, ShiptoName As String, _
' look up the BMDShipToID that might match the criteria.
    Set rs = gDBAccess.FindBMDShipTo(Branch, ShipToID, ShiptoName, ShipToCity, ShipToState, ShipToZIP)
            GetBMDShipToID = -1
            GetBMDShipToID = !BMDShipToID
    Err.Raise Err.Number, "[clsBMDSalesImport_GetBMDShipToID]" & Err.Source, Err.Description
Private Function VerifyBMDProductID(MajorMinorID As Long) As Boolean
' Can we find this product in the collection of BMDProducts?
    With rsBMDProducts
        VerifyBMDProductID = Not .EOF
    Err.Raise Err.Number, "[clsBMDSalesImport_VerifyBMDProductID]" & Err.Source, Err.Description
    Err.Raise Err.Number, "[clsBMDShipToImport_WriteStatus]" & Err.Source, Err.Description
Dim audit As clsBMDSalesImportAudit
Dim auditReport As clsBMDSalesImportAuditReport
    Set audit = New clsBMDSalesImportAudit
    Set auditReport = New clsBMDSalesImportAuditReport
    Err.Raise Err.Number, "[clsBMDSalesImport_GenerateAudit]" & Err.Source, Err.Description
    Err.Raise Err.Number, "[clsBMDSalesImport_CreateAuditReportSheet]" & Err.Source, Err.Description
    Set colBMDSales = New Collection
    If Not rsBMDProducts Is Nothing Then
        rsBMDProducts.Close
        Set rsBMDProducts = Nothing
    If Not colBMDSales Is Nothing Then
        While colBMDSales.Count > 0
            colBMDSales.Remove 1
        Set colBMDSales = Nothing

---------- BMDSALESIMPORTAUDIT.CLS
Attribute VB_Name = "clsBMDSalesImportAudit"
' BMDSalesImportAudit -- container for audit-related data on a BMD Import spreadsheet.
Dim custRec As clsBMDSalesImportAuditCustomer
    Err.Raise Err.Number, "[clsBMDSalesImportAudit_AddRecord]" & Err.source, Err.Description
Private Function getCustomer(sCustomer As String) As clsBMDSalesImportAuditCustomer
Dim cust As clsBMDSalesImportAuditCustomer
        Set cust = New clsBMDSalesImportAuditCustomer
    Err.Raise Err.Number, "[clsBMDSalesImportAudit_getCustomer]" & Err.source, Err.Description

---------- BMDSALESIMPORTAUDITCUSTOMER.CLS
Attribute VB_Name = "clsBMDSalesImportAuditCustomer"
Dim rec As clsBMDSalesImportAuditRecord
    Err.Raise Err.Number, "[clsBMDSalesImportAuditCustomer_AddRecord]" & Err.source, Err.Description
Private Function getRecord(ByVal sStatus As String) As clsBMDSalesImportAuditRecord
Dim r As clsBMDSalesImportAuditRecord
        Set r = New clsBMDSalesImportAuditRecord
    Err.Raise Err.Number, "[clsBMDSalesImportAuditCustomer.getRecord]" & Err.source, Err.Description

---------- BMDSALESIMPORTAUDITRECORD.CLS
Attribute VB_Name = "clsBMDSalesImportAuditRecord"

---------- BMDSALESIMPORTAUDITREPORT.CLS
Attribute VB_Name = "clsBMDSalesImportAuditReport"
Public Sub WriteAuditReport(shtReport As Worksheet, audit As clsBMDSalesImportAudit)
Dim cust As clsBMDSalesImportAuditCustomer
    Err.Raise Err.Number, "[clsBMDSalesImportAuditReport_WriteAuditReport]" & Err.source, Err.Description
    Err.Raise Err.Number, "[clsBMDSalesImportAuditReport_WriteHeader]" & Err.source, Err.Description
Private Function WriteCustomer(ByVal lRow As Long, cust As clsBMDSalesImportAuditCustomer) As Long
Dim rec As clsBMDSalesImportAuditRecord
    Err.Raise Err.Number, "[clsBMDSalesImportAuditReport_WriteCustomer]" & Err.source, Err.Description
Private Sub WriteRecord(ByVal lRow As Long, rec As clsBMDSalesImportAuditRecord)
    Err.Raise Err.Number, "[clsBMDSalesImportAuditReport_WriteRecord]" & Err.source, Err.Description

---------- BMDSHIPTO.CLS
Attribute VB_Name = "clsBMDShipTo"
'*** Table: BMDShipTo
Private mBMDShipToID As Long
Public Property Let BMDShipToID(ByVal vData As Long)
    mBMDShipToID = vData
Public Property Get BMDShipToID() As Long
    BMDShipToID = mBMDShipToID
    mBMDShipToID = 0
    Err.Raise Err.Number, Err.Source, "[BMDShipTo.Clear]" & Err.Description
    If mBMDShipToID > 0 Then
        AddRow = mBMDShipToID
        s = "exec BMDShipToAddRow " _
        mBMDShipToID = lResult
    Err.Raise Err.Number, "[BMDShipTo.AddRow]" & Err.Source, Err.Description
    If mBMDShipToID = 0 Then
        s = "exec BMDShipToUpdateRow " _
            & oUtil.SQLFormatNumber(mBMDShipToID, False) & "," _
    Err.Raise Err.Number, "[BMDShipTo.UpdateRow]" & Err.Source, Err.Description
    oDBRun.ExecSQL "exec BMDShipToDeleteRow " & mBMDShipToID
        mBMDShipToID = .Item("BMDShipToID")
    Err.Raise Err.Number, "[BMDShipTo.PopulateFromRow]" & Err.Source, Err.Description
    Err.Raise Err.Number, "[clsBMDShipTo_FindRetailerRegionMatch]" & Err.Source, Err.Description
    Err.Raise Err.Number, "[clsBMDShipTo_CriteriaExists]" & Err.Source, Err.Description

---------- BMDSHIPTOIMPORT.CLS
Attribute VB_Name = "clsBMDShipToImport"
Private Const BMDSHIPTO_ROWSTART As Integer = 3
' the existing BMDShipTo's in the database, for duplicate-checking
Private rsBMDShipTo As Recordset
Private colBMDShipTos As Collection ' a collection of complete and incomplete ShipTo objects
Public Property Get BMDShipToCollection() As Collection
    Set BMDShipToCollection = colBMDShipTos
Dim oCrit As clsBMDExceptionCritical
    Set oCrit = New clsBMDExceptionCritical
Dim o As clsBMDExceptionCritical
    Set o = New clsBMDExceptionCritical
Dim o As clsBMDExceptionValidate
    Set o = New clsBMDExceptionValidate
Private Sub AddException_MatchRoot(sMsg As String, RowID As Long, BMDShipTo As clsBMDShipTo)
Dim o As clsBMDExceptionMatchRoot
    Set o = New clsBMDExceptionMatchRoot
    Set o.BMDShipTo = BMDShipTo
Private Sub AddException_MatchStore(sMsg As String, RowID As Long, BMDShipTo As clsBMDShipTo)
Dim o As clsBMDExceptionMatchStore
    Set o = New clsBMDExceptionMatchStore
    Set o.BMDShipTo = BMDShipTo
    ' retrieve the current BMD Shiptos for duplicate checking.
    Set rsBMDShipTo = gDBAccess.GetAllBMDShipTo
        For lRow = BMDSHIPTO_ROWSTART To .Rows.Count
    Err.Raise Err.Number, "[clsBMDShipToImport_ParseShipTo]" & Err.source, Err.Description
Dim BMDShipTo As clsBMDShipTo
        ' isNewShipTo() determines if this record already exists in the BMDShipTo table.
            Set BMDShipTo = CreateShipTo(ShipToID, rngRow)
            MatchToRetailer BMDShipTo, rngRow
            BMDShipTo.AddRow
            colBMDShipTos.Add BMDShipTo, FW_COLLECTION_KEY & BMDShipTo.BMDShipToID
            Set BMDShipTo = gDBAccess.GetBMDShipTo(.Cells(, COL_RETAILNAME), ShipToID)
            If BMDShipTo Is Nothing Then
                Set BMDShipTo = CreateShipTo(ShipToID, rngRow)
            If BMDShipTo.RetailerRegionID > 0 Then
                MatchToRetailer BMDShipTo, rngRow
                BMDShipTo.UpdateRow
                colBMDShipTos.Add BMDShipTo, FW_COLLECTION_KEY & BMDShipTo.BMDShipToID
Private Function CreateShipTo(ShipToID As Long, rngRow As Excel.Range) As clsBMDShipTo
Dim BMDShipTo As clsBMDShipTo
        Set BMDShipTo = gDBAccess.CreateBMDShipTo
        BMDShipTo.RetailerName = .Cells(, COL_RETAILNAME)
        BMDShipTo.ShipToID = ShipToID
        BMDShipTo.Branch = .Cells(, COL_BRANCH)
        BMDShipTo.StoreNo = .Cells(, COL_STORENO)
        BMDShipTo.StoreLocation = .Cells(, COL_STORELOCATION)
        BMDShipTo.State = .Cells(, COL_STORESTATE)
    Set CreateShipTo = BMDShipTo
    Err.Raise Err.Number, "[clsBMDShipToImport_CreateShipTo]" & Err.source, Err.Description
    Err.Raise Err.Number, "[clsBMDShipToImport_ValidateRow]" & Err.source, Err.Description
    Err.Raise Err.Number, "[clsBMDShipToImport.IsRowBlank]" & Err.source, Err.Description
    With rsBMDShipTo
    Err.Raise Err.Number, "[clsBMDShipToImport.IsNewShipTo]" & Err.source, Err.Description
    Err.Raise Err.Number, "[clsBMDShipToImport_WriteStatus]" & Err.source, Err.Description
Private Sub MatchToRetailer(ByRef BMDShipTo As clsBMDShipTo, rngRow As Excel.Range)
    sRetailerName = BMDShipTo.RetailerName
        Set rsRetailRoot = gDBAccess.FindBMDRetailerRoot(sRetailerName)
        MatchToRetailerStore lRetailerRegionParentID, BMDShipTo, rngRow
        AddException_MatchRoot "Retailer Root: " & BMDShipTo.RetailerName & " not found.", rngRow.row, BMDShipTo
        WriteStatus rngRow, "Retailer Root:" & BMDShipTo.RetailerName & " not found!"
                                      ByRef BMDShipTo As clsBMDShipTo, _
    If Not BMDShipTo.FindRetailerRegionMatch(sRetailers, SearchStatus) Then
        AddException_MatchStore "Couldn't Match Store: " & SearchStatus, rngRow.row, BMDShipTo
    Err.Raise Err.Number, "[clsBMDShipToImport_MatchToRetailerStore]" & Err.source, Err.Description
    Set colBMDShipTos = New Collection

---------- DB.CLS
Private Const ERR_BAD_BMD_DISTRO_ID = vbObjectError + 512 + 5001
Public Function CreateBMDProduct() As clsBMDProduct
Dim b As clsBMDProduct
    Set b = New clsBMDProduct
    Set CreateBMDProduct = b
    Err.Raise Err.Number, "[clsDB_CreateBMDProduct]" & Err.Source, Err.Description
Public Function CreateBMDShipTo() As clsBMDShipTo
Dim b As clsBMDShipTo
    Set b = New clsBMDShipTo
    Set CreateBMDShipTo = b
    Err.Raise Err.Number, "[clsDB_CreateBMDShipTo]" & Err.Source, Err.Description
Public Function CreateBMDSales() As clsBMDSales
Dim b As clsBMDSales
    Set b = New clsBMDSales
    Set CreateBMDSales = b
    Err.Raise Err.Number, "[clsDB_CreateBMDSales]" & Err.Source, Err.Description
Public Function CreateBMDBatch(importFileName As String) As clsBMDBatch
Dim b As clsBMDBatch
    Set b = New clsBMDBatch
    Set CreateBMDBatch = b
    Err.Raise Err.Number, "[clsDB_CreateBMDBatch]" & Err.Source, Err.Description
    '(BMD_DistributorRegionID) to indicate the "Boise Cascade BMD - Locations" data.
            "?", CStr(BMD_DistributorRegionID), , 1), _
    Optional ByVal ExcludeBMD As Boolean) As Collection
            '2008-Mar-28: Add option to exclude BMD from the list.
            If Not ExcludeBMD Or .Fields("DistributorRegionID").Value <> BMD_DistributorRegionID Then
Public Function GetBMDProductByProductTypeID(ProductTypeID As Variant) As Recordset
' Retrieve a recordset of BMDProduct entries that match this ProductTypeID.
' If IsNull(ProductTypeID), this returns all the BMDProduct NOT associated with a ProductTypeID.
    sql = "SELECT MajorMinorID, BMDProductDesc FROM BMDProduct WHERE " & sqlCriteria & " ORDER BY MajorMinorID "
    Set GetBMDProductByProductTypeID = oDBExec.ExecSimpleSQL(sql)
    Err.Raise Err.Number, "[clsDB_GetBMDProductByProductTypeID]" & Err.Source, Err.Description
Public Function GetAllBMDProduct() As Recordset
' retrieve the entire BMDProduct table, in a RW recordset.
    Set GetAllBMDProduct = oDBExec.RunSQLReturnRS_RW("SELECT * FROM BMDProduct")
    Err.Raise Err.Number, "[clsDB_GetAllBMDProduct]" & Err.Source, Err.Description
Public Function GetAllBMDProduct_WithDesc() As Recordset
' Recordset of all BMDProducts with their ProductDescs, if they have one.
    sql = "SELECT BMDP.*, P.ProductDesc as 'SAProductDesc' " & _
          "FROM BMDProduct BMDP LEFT OUTER JOIN Product P ON BMDP.ProductTypeID = P.ProductTypeID " & _
          "ORDER BY BMDP.MajorMinorID"
    Set GetAllBMDProduct_WithDesc = oDBExec.ExecSimpleSQL(sql)
    Err.Raise Err.Number, "[clsDB_GetAllBMDProduct_WithDesc]" & Err.Source, Err.Description
Public Function BMDProductMajorMinorIDExists(MajorMinorID As Long) As Boolean
    sql = "SELECT MajorMinorID FROM BMDProduct WHERE MajorMinorID = " & MajorMinorID
        BMDProductMajorMinorIDExists = Not (.BOF And .EOF)
    Err.Raise Err.Number, "[clsDB_BMDProductMajorMinorIDExists]" & Err.Source, Err.Description
Public Function GetBMDProduct(MajorMinorID As Long) As clsBMDProduct
' retrieve the BMDProduct that goes to this MajorMinor ID, or return Nothing
Dim bp As clsBMDProduct
    sql = "SELECT * FROM BMDProduct WHERE MajorMinorID = " & MajorMinorID
            Set GetBMDProduct = Nothing
            Set bp = New clsBMDProduct
            Set GetBMDProduct = bp
    Err.Raise Err.Number, "[clsDB_GetBMDProduct]" & Err.Source, Err.Description
Public Function GetBMDShipTo(RetailName As String, ShipToID As Long) As clsBMDShipTo
Dim bst As clsBMDShipTo
    Set rs = oDBExec.RunSQLReturnRS("SELECT * FROM BMDShipTo " & _
            Set GetBMDShipTo = Nothing
            Set bst = New clsBMDShipTo
            Set GetBMDShipTo = bst
    Err.Raise Err.Number, "[clsDB_GetBMDShipTo]" & Err.Source, Err.Description
Public Function GetBMDSalesRecord(BMDSalesID As Long) As clsBMDSales
Dim bsr As clsBMDSales
    Set rs = oDBExec.RunSQLReturnRS("SELECT * FROM BMDSales WHERE BMDSalesID = " & BMDSalesID)
            Set GetBMDSalesRecord = Nothing
            Set bsr = New clsBMDSales
            Set GetBMDSalesRecord = bsr
    Err.Raise Err.Number, "[clsDB_GetBMDSalesRecord]" & Err.Source, Err.Description
Public Function GetAllBMDShipTo() As Recordset
' retrieve all of the BMDShipTo records stored so far.
    sql = "SELECT BMDShipTo.*, RetailerRegion.RetailerRegionDesc " & _
          "FROM BMDShipTo LEFT OUTER JOIN RetailerRegion ON BMDShipTo.RetailerRegionID = RetailerRegion.RetailerRegionID " & _
          "WHERE BMDShipTo.Deleted = 0 " & _
    Set GetAllBMDShipTo = oDBExec.RunSQLReturnRS_RW(sql)
    Err.Raise Err.Number, "[clsDB_GetAllBMDShipTo]" & Err.Source, Err.Description
Public Function GetAllBMDShipTo_Chooser() As Recordset
' retrieve all the BMDShipTo's, in Chooser format.
          " R.RetailerRegionDesc, R.RetailerRegionID, B.BMDShipToID " & _
          "FROM BMDShipTo B LEFT OUTER JOIN RetailerRegion R ON B.RetailerRegionID = R.RetailerRegionID " & _
    Set GetAllBMDShipTo_Chooser = oDBExec.RunSQLReturnRS_RW(sql)
    Err.Raise Err.Number, "[clsDB_GetAllBMDShipTo_Chooser]" & Err.Source, Err.Description
Public Function GetAllBMDSales() As Recordset
                 "S.BMDSalesID, " & _
                 "S.BMDShipToID, " & _
        "FROM BMDSales S LEFT OUTER JOIN BMDProduct ON S.MajorMinorID = BMDProduct.MajorMinorID " & _
          "LEFT OUTER JOIN BMDShipTo SHIP ON S.BMDShipToID = SHIP.BMDShipToID " & _
          "LEFT OUTER JOIN Product P ON BMDProduct.ProductTypeID = P.ProductTypeID " & _
    Set GetAllBMDSales = oDBExec.RunSQLReturnRS_RW(sql)
    Err.Raise Err.Number, "[clsDB_GetAllBMDSales]" & Err.Source, Err.Description
Public Function GetAllBMDSalesTotal() As Currency
           "FROM BMDSales S WHERE S.Imported = 0 AND S.Deleted = 0"
                GetAllBMDSalesTotal = !SalesTotal
    Err.Raise Err.Number, "[clsDB_GetAllBMDSalesTotal]" & Err.Source, Err.Description
Public Sub UpdateMatchingBMDSalesRecords(BMDSalesID As Long)
' find other, unmatched, BMDSales records that are similar to the given ID,
' and set them to the BMDShipToID given.
    sql = "UPDATE Dest set Dest.BMDShipToID = Src.BMDShipToID " & _
          "FROM BMDSales Dest, BMDSales Src " & _
            "Dest.BMDShipToID = -1 and " & _
            "Src.BMDSalesID = " & BMDSalesID & " and " & _
    Err.Raise Err.Number, "[clsDB_UpdateMatchingBMDSalesRecords]" & Err.Source, Err.Description
Public Sub AssociateBMDSaleToBMDShipTo(BMDSalesID As Long, BMDShipToID As Long)
    sql = "UPDATE BMDSales SET BMDShipToID = " & BMDShipToID & " WHERE BMDSalesID = " & BMDSalesID
    Err.Raise Err.Number, "[clsDB_AssociateBMDSaleToBMDShipTo]" & Err.Source, Err.Description
Public Sub AssociateBMDShipToRetailer(BMDShipToID As Long, RetailerRegionID As Long)
' associate this BMDShipToID record with the given RetailerRegionID.
    sql = "UPDATE BMDShipTo SET RetailerRegionID = "
    sql = sql & " WHERE BMDShipToID = " & BMDShipToID
    Err.Raise Err.Number, "[clsDB_AssociateBMDShipToRetailer]" & Err.Source, Err.Description
Public Sub DeleteBMDShipTo(BMDShipToID As Long)
' delete this BMDShipTo record and all data associated with it.
    oDBExec.ExecSimpleSQL "exec BMDShipToDeleteRow " & BMDShipToID
    Err.Raise Err.Number, "[clsDB_DeleteBMDShipTo]" & Err.Source, Err.Description
' delete this BMDShipTo record and all data associated with it.
Public Sub DeleteBMDSales(BMDSalesID As Long)
    'oDBExec.ExecSimpleSQL "exec BMDSalesDeleteRow " & BMDSalesID
    'oDBExec.ExecSimpleSQL "DELETE BMDSales WHERE BMDSalesID = " & BMDSalesID
    oDBExec.ExecSimpleSQL "exec BMDSalesDeleteRow " & BMDSalesID
    Err.Raise Err.Number, "[clsDB_DeleteBMDSales]" & Err.Source, Err.Description
Public Sub ChangeBMDProductIndex(MajorMinorID As Long, ProductTypeID As Variant)
    sql = "UPDATE BMDProduct SET ProductTypeID = " & objUtil.SQLFormatNumber(ProductTypeID, True) & _
    Err.Raise Err.Number, "[clsDB_ChangeBMDProductIndex]" & Err.Source, Err.Description
Public Function FindBMDRetailerRoot(RetailerName As String) As Recordset
        Err.Raise ERR_BAD_RETAILERNAME, "[clsDB.FindBMDRetailerRoot]", "RetailerName length must be > 0"
    Set FindBMDRetailerRoot = oDBExec.RunSQLReturnRS(sql)
    Err.Raise Err.Number, "[clsDB_FindBMDRetailerRoot]" & Err.Source, Err.Description
Public Function FindBMDShipTo(Branch As String, ShipToID As Long, ShiptoName As String, _
' look for a BMDShipTo record that matches these parameters.
    sql = "SELECT st.BMDShipToID, Difference(st.RetailerName, " & oUtil.SQLFormatChar(ShiptoName, False) & ") as RetailDiff " & _
          "FROM BMDShipTo AS st LEFT JOIN RetailerRegion AS rr ON rr.RetailerRegionID = st.RetailerRegionID " & _
         "ORDER BY RetailDiff desc, st.BMDShipToID DESC"
    Set FindBMDShipTo = oDBExec.RunSQLReturnRS(sql)
    'Debug.Assert FindBMDShipTo.RecordCount <= 1
    Err.Raise Err.Number, "[clsDB_FindBMDShipTo]" & Err.Source, Err.Description
Public Sub UpdateBMDSalesData()
' move completed BMDSales entries to RetailerRegionSales (via Distro-Retail-Region),
Dim lBMDID As Long
    lBMDID = gAppSetting.BMDDistroID
    If lBMDID < 1 Then
        Err.Raise ERR_BAD_BMD_DISTRO_ID, "[clsDB.UpdateBMDSalesData]", _
                  "Can't update BMD ShipTo's, BMD Distributor ID has not been set."
    oDBExec.ExecSimpleSQL "exec UpdateBMDSalesData "    '& lBMDID
    Err.Raise Err.Number, "[clsDB_UpdateBMDShipToDistroRetail]" & Err.Source, Err.Description
Dim lBMDID As Long
    lBMDID = gAppSetting.BMDDistroID
    If lBMDID < 1 Then
        Err.Raise ERR_BAD_BMD_DISTRO_ID, "[clsDB.UpdateBMDSalesData]", _
                  "Can't update BMD ShipTo's, BMD Distributor ID has not been set."
    oDBExec.ExecSimpleSQL "exec UpdateBMDSalesData " '& lBMDID
    Err.Raise Err.Number, "[clsDB_UpdateBMDShipToDistroRetail]" & Err.Source, Err.Description

---------- DISTRORETAILEXPORT.CLS
        '2008-Mar-28: Exclude the sheet for the BMD locations.
        If dr.DistributorRegionID <> BMD_DistributorRegionID Then

---------- DIXIESALESIMPORT.CLS
' THE Dixie IMPORT MANIFESTO (adapted from BMD import)
            ' Dixie doesn't have the same set of data columns as BMD; verify that this is still enough data
            ' The Dixie Product ID (cleverly disguised using the BMD name)

---------- DIXIESHIPTOIMPORT.CLS
' This is cloned from BMD; not sure that Dixie has a ShipToImport

---------- IBMDEXCEPTION.CLS
Attribute VB_Name = "IBMDException"
'  Exception generated by the BMD ShipTo Import process.
' what type of exception is this, actually?  (see BMD.bas for definitions)
Public Property Get ExceptionType() As BMDImportExceptionType

---------- REPORT_BMDBATCH.CLS
Attribute VB_Name = "Report_BMDBatch"
Private Const csClassName As String = "Report_BMDBatch"
Private Const csTemplateDetailFileName As String = "BMDBatchDetail"
Private Const csReportSummary As String = "EXEC BMDBatchReport ?"
                             Optional ByVal bBMDOnly As Boolean = True) As String
    PopulateReportDetail bBMDOnly
Private Sub PopulateReportDetail(Optional ByVal bBMDOnly As Boolean)
    If bBMDOnly Then

---------- REPORT_BUILDERSALES.CLS
'    Dim bBMDOnly As Boolean
'    bBMDOnly = (fCaller.chkBMDOnly.Value = 1)
'    sql = Replace(sql, "?", oUtil.SQLFormatNumber(bBMDOnly, False), , 1)
'        If bBMDOnly Then sql = sql & "BMD "

---------- REPORT_MARGINANALYSIS.CLS
'Private Const cnBMD_ONLY = -1       'Only BMD
'Private Const cnBMD_ALL = 0         'All Retailers
'Private Const cnBMD_EXCLUDED = 1    'All except BMD
'    Dim bBMDOnly As Boolean
'    bBMDOnly = (fCaller.chkBMDOnly.Value = 1)
'    sql = Replace(sql, "?", oUtil.SQLFormatNumber(bBMDOnly, False), , 1)
'        If bBMDOnly Then sql = sql & "BMD "
'    Dim bBMDOnly As Boolean
'    bBMDOnly = (fCaller.chkBMDOnly.Value = 1)
'    sql = Replace(sql, "?", oUtil.SQLFormatNumber(bBMDOnly, False), , 1)
'        If bBMDOnly Then sql = sql & "BMD "

---------- REPORT_RETAILSALES.CLS
'Private Const cnBMD_ONLY = -1       'Only BMD
'Private Const cnBMD_ALL = 0         'All Retailers
'Private Const cnBMD_EXCLUDED = 1    'All except BMD
    Dim bBMDOnly As Boolean
    bBMDOnly = (fCaller.chkBMDOnly.Value = 1)
    sql = Replace(sql, "?", oUtil.SQLFormatNumber(bBMDOnly, False), , 1)
        If bBMDOnly Then sql = sql & "BMD "
    Dim bBMDOnly As Boolean
    bBMDOnly = (fCaller.chkBMDOnly.Value = 1)
    sql = Replace(sql, "?", oUtil.SQLFormatNumber(bBMDOnly, False), , 1)
        If bBMDOnly Then sql = sql & "BMD "
    Dim lOptionBMD As Long
            '2012-Dec-18: Add BMD only option.
            '    .BuildParamArrayElement("@List_Options", adInteger, 4, cnBMD_ALL))
            lOptionBMD = cnBMD_ALL
            If fCaller.chkBMDOnly.Value = 1 Then lOptionBMD = OPTION_BMD_ONLY
                .BuildParamArrayElement("@ReportOptions", adInteger, 4, lOptionBMD))

---------- BMDPRODUCT.FRM
Begin VB.Form fBMDProduct 
   Caption         =   "BMD Products"
   Icon            =   "BMDProduct.frx":0000
   Begin VSFlex8Ctl.VSFlexGrid grdBMDProduct 
      FormatString    =   $"BMDProduct.frx":08CA
      Caption         =   "BMD Products Assigned to Product IDs:"
      Caption         =   "BMD Products NOT assigned:"
Attribute VB_Name = "fBMDProduct"
'  Managing BMD Products <--> ProductTypeIDs
Private Const COL_BMD_DESC = 2
    Err.Raise Err.Number, "[fBMDProduct_GetCurrentListBox]" & Err.Source, Err.Description
    Err.Raise Err.Number, "[fBMDProduct_cmdAddProduct_Click]" & Err.Source, Err.Description
    With grdBMDProduct
            lst.AddItem .Cell(flexcpText, iMyRow, COL_MAJMIN) & vbTab & .Cell(flexcpText, iMyRow, COL_BMD_DESC)
            gDBAccess.ChangeBMDProductIndex .Cell(flexcpText, iMyRow, COL_MAJMIN), lst.Tag
    Err.Raise Err.Number, "[fBMDProduct.AddProduct]" & Err.Source, Err.Description
    ReportError Err, "[fBMDProduct.cmdDone]"
    Load fBMDProductAddNew
    With fBMDProductAddNew
    ReportError Err, "[fBMDProduct_cmdInsert_Click]"
            grdBMDProduct.AddItem vbTab & .List(.ListIndex)
            gDBAccess.ChangeBMDProductIndex .ItemData(.ListIndex), Null
    Err.Raise Err.Number, "[fBMDProduct_cmdRemoveProduct_Click]" & Err.Source, Err.Description
    ReportError Err, "[fBMDProduct_Form_Load]"
    Err.Raise Err.Number, "[fBMDProduct_InitTabStrip]" & Err.Source, Err.Description
' load each Product container (listbox for now) with the BMD products
        ' retrieve the recordset of BMD product
        Set rsProducts = gDBAccess.GetBMDProductByProductTypeID(ProductTypeID)
                lst.AddItem !MajorMinorID & vbTab & !BMDProductDesc
    Err.Raise Err.Number, "[fBMDProduct_LoadProductListBox]" & Err.Source, Err.Description
' load those BMD records that are NOT assigned to any product.
    Set rsProducts = gDBAccess.GetBMDProductByProductTypeID(Null)
    ClearGrid grdBMDProduct
            grdBMDProduct.AddItem vbTab & !MajorMinorID & vbTab & !BMDProductDesc
    Err.Raise Err.Number, "[fBMDProduct_LoadUnassignedProducts]" & Err.Source, Err.Description
' Import a spreadsheet containing the list of BMD products
Dim BMDProductImport As clsBMDProductImport
    If MsgBox("Import Products from the BMD Product Spreadsheet?", vbYesNo, "Confirm Import") = vbYes Then
        Set BMDProductImport = New clsBMDProductImport
        lProcessed = BMDProductImport.Import(Me)
        If BMDProductImport.HasErrors Then
        If BMDProductImport.HasErrors Then
            DisplayErrors BMDProductImport.ErrorMessages, BMDProductImport.ErrorCount
    ReportError Err, "[fBMDProduct_mnuToolsImportProduct_Click]"
    ReportError Err, "[fBMDProduct_tsProduct_BeforeClick]"
    ReportError Err, "[fBMDProduct_tsProduct_Click]"

---------- BMDPRODUCTADDNEW.FRM
Begin VB.Form fBMDProductAddNew 
   Caption         =   "BMD Product Add New"
   Icon            =   "BMDProductAddNew.frx":0000
   Begin VB.TextBox txtBMDDesc 
      Caption         =   "BMD Desc:"
Attribute VB_Name = "fBMDProductAddNew"
    ReportError Err, "[fBMDProductAddNew_cmdOK_Click]"
    ReportError Err, "[fBMDProductAddNew_Form_Load]"
Dim bmdProduct As clsBMDProduct
    Set bmdProduct = gDBAccess.CreateBMDProduct
    With bmdProduct
        .BMDProductDesc = txtBMDDesc.Text
    Err.Raise Err.Number, "[fBMDProductAddNew_SaveRecord]" & Err.Source, Err.Description
    If Len(txtBMDDesc.Text) = 0 Then
        sMsg = sMsg & "Please enter a BMD description." & vbCrLf
        If gDBAccess.BMDProductMajorMinorIDExists(txtMajorMinorID.Text) Then
    Err.Raise Err.Number, "[fBMDProductAddNew_ValidateForm]" & Err.Source, Err.Description

---------- BMDPRODUCTCHOOSE.FRM
Begin VB.Form fBMDProductChoose 
   Caption         =   "Select BMD Product"
   Icon            =   "BMDProductChoose.frx":0000
Attribute VB_Name = "fBMDProductChoose"
Private Const LEN_BMDPRODUCTDESC As Integer = 30
    Err.Raise Err.Number, "[fBMDProductChoose_MajorMinorID]" & Err.Source, Err.Description
    ReportError Err, "[fBMDProductChoose_cmdNoSelection_Click]"
    ' BMDProductDesc
    ts(1) = LEN_BMDPRODUCTDESC * 4 ' chars for BMD Product Desc
    ReportError Err, "[fBMDProductChoose.Form_Load]"
    'Set rs = gDBAccess.GetAllBMDProduct_WithDesc
    Set rs = gDBAccess.GetAllBMDProduct
            'lstProducts.AddItem !MajorMinorID & vbTab & Left$(!BMDProductDesc & vbNullString, LEN_BMDPRODUCTDESC) & vbTab & Left$(!SAProductDesc & vbNullString, LEN_SAPRODUCTDESC)
            lstProducts.AddItem !MajorMinorID & vbTab & !BMDProductDesc
    Err.Raise Err.Number, "[fBMDProductChoose_PopulateListBox]" & Err.Source, Err.Description

---------- BMDSALESADDNEW.FRM
Begin VB.Form fBMDSalesAddNew 
   Caption         =   "BMD Sales Add New"
   Icon            =   "BMDSalesAddNew.frx":0000
   Begin VB.CommandButton cmdBMDShipToID 
   Begin VB.TextBox txtBMDShipToID 
      Caption         =   "BMD ShipTo ID:"
Attribute VB_Name = "fBMDSalesAddNew"
Private Sub cmdBMDShipToID_Click()
    Load fBMDShipToChoose
    With fBMDShipToChoose
        If IsNumeric(txtBMDShipToID.Text) Then
            .LoadData txtBMDShipToID.Text
            txtBMDShipToID.Text = .BMDShipToID
            txtBMDShipToID.Text = vbNullString
    ReportError Err, "[fBMDSalesAddNew_cmdBMDShipToID_Click]"
    Load fBMDProductChoose
    With fBMDProductChoose
    Unload fBMDProductChoose
    ReportError Err, "[fBMDSalesAddNew_cmdMajorMinorID_Click]"
    ReportError Err, "[fBMDSalesAddNew_cmdOK_Click]"
Dim bmdSales As clsBMDSales
    Set bmdSales = gDBAccess.CreateBMDSales
    With bmdSales
        .BMDShipToID = txtBMDShipToID.Text
    Err.Raise Err.Number, "[fBMDSalesAddNew_SaveRecord]" & Err.Source, Err.Description
    If Not IsNumeric(txtBMDShipToID.Text) Then
        txtBMDShipToID = -1
    Err.Raise Err.Number, "[fBMDSalesAddNew_ValidateForm]" & Err.Source, Err.Description

---------- BMDSALESENTRY.FRM
Begin VB.Form fBMDSalesEntry 
   Caption         =   "BMD Sales Entry"
   Icon            =   "BMDSalesEntry.frx":0000
      FormatString    =   $"BMDSalesEntry.frx":08CA
      Begin VB.Menu mnuEditSelectBMD 
         Caption         =   "Select BMD Distributor"
         Caption         =   "BMD Products"
         Caption         =   "Import BMD Sales"
      Caption         =   "BMDSales"
Attribute VB_Name = "fBMDSalesEntry"
Private Const COL_BMDSALESID As Integer = 8
Private Const COL_BMDSHIPTOID As Integer = 9
Private Const COL_BMDRETAILNAME As Integer = 10
Private rsBMDSales As Recordset
Private lBMDSalesID_ShipToEdit As Long
                    gDBAccess.DeleteBMDSales .Cell(flexcpValue, .row, COL_BMDSALESID)
    ReportError Err, "[fBMDSalesEntry_cmdDelete_Click]"
            gDBAccess.DeleteBMDSales .Cell(flexcpValue, iMyRow, COL_BMDSALESID)
            ' we're losing ShipTo's, BMDProductIDs, and BMDShipTos.
    Err.Raise Err.Number, "[fBMDSalesEntry_MultiDeleteSales]" & Err.Source, Err.Description
    Load fBMDSalesAddNew
    With fBMDSalesAddNew
    Unload fBMDSalesAddNew
    ReportError Err, "[fBMDSalesEntry_cmdInsert_Click]"
    ReportError Err, "[fBMDSalesEntry_Form_Load]"
    ReportError Err, "[fBMDSalesEntry_Form_Resize]"
        .ColHidden(COL_BMDSHIPTOID) = True
        .ColHidden(COL_BMDSALESID) = True
    ReportError Err, "[fBMDSalesEntry_grdSales_AfterDataRefresh]"
        .Cell(flexcpText, ROW_DATASOURCE, COL_BMDSALESID) = "Imported Data"
        .Cell(flexcpText, ROW_FIELDNAMES, COL_BMDSALESID) = "BMDSalesID"
        .Cell(flexcpText, ROW_DATASOURCE, COL_BMDSHIPTOID) = "Imported Data"
        .Cell(flexcpText, ROW_FIELDNAMES, COL_BMDSHIPTOID) = "BMDShipToID"
        .Cell(flexcpText, ROW_DATASOURCE, COL_BMDRETAILNAME) = "BMD ShipTo Data"
        .Cell(flexcpText, ROW_FIELDNAMES, COL_BMDRETAILNAME) = "Name"
        .Cell(flexcpText, ROW_DATASOURCE, COL_SHIPTOID) = "BMD ShipTo Data"
        .Cell(flexcpText, ROW_DATASOURCE, COL_STORELOCATION) = "BMD ShipTo Data"
    Err.Raise Err.Number, "[fBMDSalesEntry_updateHeader]" & Err.Source, Err.Description
Dim lBMDSalesID As Long
Dim lBMDShipToID As Long
            lBMDSalesID = grdSales.Cell(flexcpValue, row, COL_BMDSALESID)
            Load fBMDShipToChoose
            With fBMDShipToChoose
                .LoadData lBMDShipToID
                    lBMDShipToID = .BMDShipToID
                    UpdateBMDSales_ShipTo lBMDSalesID, lBMDShipToID
    ReportError Err, "[fBMDSalesEntry_grdSales_CellButtonClick]"
Private Sub UpdateBMDSales_ShipTo(BMDSalesID As Long, BMDShipToID As Long)
' update a BMDSales record with BMDShipToinformation.
    gDBAccess.AssociateBMDSaleToBMDShipTo BMDSalesID, BMDShipToID
    MatchAssociatedShipTos BMDSalesID
    Err.Raise Err.Number, "[fBMDSalesEntry_UpdateBMDSales_ShipTo]" & Err.Source, Err.Description
Private Sub MatchAssociatedShipTos(BMDSalesID As Long)
        gDBAccess.UpdateMatchingBMDSalesRecords BMDSalesID
    Err.Raise Err.Number, "[fBMDSalesEntry_MatchAssociatedShipTos]" & Err.Source, Err.Description
    ReportError Err, "[fBMDSalesEntry_grdSales_MouseDown]"
Dim oSales As clsBMDSales
        ' load the BMDShipTo add form, populate it with data from the selected item.
        Load fBMDShipToAdd
        Set fBMDShipToAdd.Caller = Me
        Set oSales = gDBAccess.GetBMDSalesRecord(.Cell(flexcpValue, .row, COL_BMDSALESID))
            MsgBox "Error: Couldn't load BMDSales Record.  Aborted.", vbOKOnly + vbCritical, "Error"
        lBMDSalesID_ShipToEdit = .Cell(flexcpValue, .row, COL_BMDSALESID)
        fBMDShipToAdd.Populate oSales
        fBMDShipToAdd.Show vbModal
        ' when this method returns, we get called back by AddNewBMDShipTo(), below
    ReportError Err, "[fBMDSalesEntry_mnuEditCreateShipTo]"
Public Sub AddNewBMDShipTo(bmdShipTo As clsBMDShipTo, RetailerRegionDesc As String)
' callback function from fBMDShipToAdd -- when a new shipto record has been created.
    UpdateBMDSales_ShipTo lBMDSalesID_ShipToEdit, bmdShipTo.BMDShipToID
    Err.Raise Err.Number, "[fBMDSalesEntry_AddNewBMDShipTo]" & Err.Source, Err.Description
    ReportError Err, "[fBMDSalesEntry_mnuEditDelete_Click]"
    ReportError Err, "[fBMDSalesEntry_mnuEditInsert_Click]"
        MatchAssociatedShipTos .Cell(flexcpValue, .row, COL_BMDSALESID)
    Err.Raise Err.Number, "[fBMDSalesEntry_mnuEditMatch_Click]" & Err.Source, Err.Description
    ReportError Err, "[fBMDSalesEntry_mnuEditRefreshGrid_Click]"
Private Sub mnuEditSelectBMD_Click()
    DisplaySelectBMDDistro
    ReportError Err, "[fBMDSalesEntry_mnuEditSelectBMD_Click]"
    ReportError Err, "[fBMDSalesEntry_mnuGridPopupDeleteRec_Click]"
    ReportError Err, "[fBMDSalesEntry_mnuGridPopupMatchShipTo_Click]"
    ReportError Err, "[fBMDSalesEntry_mnuGridPopupNewShipTo_Click]"
Dim bmdImport As clsBMDSalesImport
        MsgBox "You must complete the current batch of BMD Sales before importing new data.", vbOKOnly, "One Batch At A Time"
    Set bmdImport = New clsBMDSalesImport
    bmdImport.Import Me, pbarMgr
    ' (write a record to the BMD Event table)
    If Not bmdImport.BatchDetails Is Nothing Then
        Debug.Print "Rows: " & bmdImport.BatchDetails.TotalRows & " Sum: " & bmdImport.BatchDetails.TotalSales
    Set bmdImport = Nothing
'    If bmdImport.HasExceptions Then
'        Load fBMDSalesExceptions
'        Set fBMDSalesExceptions.BMDSalesImport = bmdImport
'        fBMDSalesExceptions.Show vbModal
    ReportError Err, "[fBMDSalesEntry_mnuToolsImport_Click]"
' gather all the complete and importable rows in the BMDSales table and
    gDBAccess.UpdateBMDSalesData
    fBMDProduct.Show
    fBMDShipTo.Show
    Set rsBMDSales = gDBAccess.GetAllBMDSales
    Set grdSales.DataSource = rsBMDSales
    sbar.Panels(1).Text = "Records: " & (grdSales.Rows - grdSales.FixedRows) & " Total Sales: " & Format$(gDBAccess.GetAllBMDSalesTotal(), "currency")
    Err.Raise Err.Number, "[fBMDSalesEntry_PopulateGrid]" & Err.Source, Err.Description
Private Sub DisplaySelectBMDDistro()
' pick the distributor that is associated with these BMD Sales records.
Dim lBMDDistroID As Long
    lBMDDistroID = gAppSetting.BMDDistroID
        .LoadData lBMDDistroID
            lBMDDistroID = .DistributorRegionID
            gAppSetting.BMDDistroID = lBMDDistroID
    Err.Raise Err.Number, "[fBMDSalesEntry_DisplaySelectBMDDistro]" & Err.Source, Err.Description

---------- BMDSALESEXCEPTIONS.FRM
Begin VB.Form fBMDSalesExceptions 
   Caption         =   "BMD Sales Exceptions"
   Icon            =   "BMDSalesExceptions.frx":0000
      FormatString    =   $"BMDSalesExceptions.frx":08CA
Attribute VB_Name = "fBMDSalesExceptions"
Private BMDSalesGenerator As clsBMDSalesImport
Private colBMDSales As Collection
Private Const COL_BMDPRODDESC           As Integer = 7
Private Const COL_BMDSHIPTOID           As Integer = 9
Public Property Set BMDSalesImport(o As clsBMDSalesImport)
    Set BMDSalesGenerator = o
    Set colBMDSales = BMDSalesGenerator.BMDSalesCollection
    grdExceptions.ColComboList(COL_BMDSHIPTOID) = "..."
    ReportError Err, "[fBMDSalesExceptions_Form_Load]"
Dim oExcept As IBMDException
    Set colExceptions = BMDSalesGenerator.Exceptions
            Case BMDEXCEPTION_CRITICAL
            Case BMDEXCEPTION_MATCHSHIPTO
            Case BMDEXCEPTION_MATCHPRODUCT
    Err.Raise Err.Number, "[fBMDSalesExceptions_PopulateGrid]" & Err.Source, Err.Description
Private Sub AddException_Critical(critExcept As clsBMDExceptionCritical)
    Err.Raise Err.Number, "[fBMDSalesExceptions_AddException_Critical]" & Err.Source, Err.Description
Private Sub AddException_MatchShipTo(matchExcept As clsBMDExceptionMatchShipto)
Dim bmdProduct As clsBMDProduct
    Set bmdProduct = gDBAccess.GetBMDProduct(matchExcept.bmdSales.MajorMinorID)
    If Not bmdProduct Is Nothing Then
        If Not IsNull(bmdProduct.ProductTypeID) Then
            Set prod = gDBAccess.GetProduct(bmdProduct.ProductTypeID)
               .bmdSales.SalesAmt & vbNullString, _
               .bmdSales.ShiptoName & vbNullString, _
               .bmdSales.MajorMinorID & vbNullString, _
               .bmdSales.BMDProductDesc & vbNullString, _
               .bmdSales.BMDShipToID & vbNullString, _
               .bmdSales.BMDSalesID & vbNullString
    Err.Raise Err.Number, "[fBMDSalesExceptions_AddException_MatchShipTo]" & Err.Source, Err.Description
Private Sub AddException_MatchProduct(matchExcept As clsBMDExceptionMatchProduct)
               .bmdSales.SalesAmt & vbNullString, _
               .bmdSales.ShiptoName & vbNullString, _
               .bmdSales.MajorMinorID & vbNullString, _
               .bmdSales.BMDProductDesc & vbNullString, _
               .bmdSales.BMDShipToID & vbNullString, _
               .bmdSales.BMDSalesID & vbNullString
    Err.Raise Err.Number, "[fBMDSalesExceptions_AddException_MatchProduct]" & Err.Source, Err.Description
                   Optional ByVal BMDProductDesc As String = vbNullString, _
                   Optional ByVal BMDShipToID As String = vbNullString, _
                   Optional ByVal BMDSalesID As Long = 0)
                 MajorMinorID & vbTab & BMDProductDesc & vbTab & ProductDesc & vbTab & _
                 BMDShipToID
        .RowData(.Rows - 1) = BMDSalesID
    Err.Raise Err.Number, "[fBMDSalesExceptions.AddRow]" & Err.Source, Err.Description
Dim lBMDSalesID As Long
Dim lBMDShipToID As Long
Dim bmdSales As clsBMDSales
    lBMDSalesID = grdExceptions.RowData(row)
    If lBMDSalesID > 0 Then
        ' go to select-a-BMDShipTo screen
        Load fBMDShipToChoose
        With fBMDShipToChoose
            .LoadData lBMDShipToID
                grdExceptions.Cell(flexcpText, row, COL_BMDSHIPTOID) = .BMDShipToID
                Set bmdSales = colBMDSales(FW_COLLECTION_KEY & grdExceptions.RowData(row))
                bmdSales.BMDShipToID = .BMDShipToID
                bmdSales.UpdateRow
    ReportError Err, "[fBMDSalesExceptions_grdExceptions_CellButtonClick]"
Private Sub mnuEditBMDProduct_Click()
    fBMDProduct.Show vbModal
Private Sub mnuEditBMDShipto_Click()
    fBMDShipTo.Show vbModal
    ReportError Err, "[fBMDSalesExceptions_mnuEditRefresh_Click]"

---------- BMDSHIPTO.FRM
Begin VB.Form fBMDShipTo 
   Caption         =   "BMD ShipTo Entry"
   Icon            =   "BMDShipTo.frx":0000
      FormatString    =   $"BMDShipTo.frx":08CA
Attribute VB_Name = "fBMDShipTo"
                    gDBAccess.DeleteBMDShipTo .RowData(.row)
    Err.Raise Err.Number, "[fBMDShipTo_cmdDelete_Click]" & Err.Source, Err.Description
            gDBAccess.DeleteBMDShipTo .RowData(iMyRow)
    Err.Raise Err.Number, "[fBMDShipTo_MultiDeleteShipTo]" & Err.Source, Err.Description
    Load fBMDShipToAdd
    With fBMDShipToAdd
    Err.Raise Err.Number, "[fBMDShipTo.cmdInsert_Click]", Err.Description
Public Sub AddNewBMDShipTo(bmdShipTo As clsBMDShipTo, RetailerRegionDesc As String)
    With bmdShipTo
                   .State, RetailerRegionDesc, .RetailerRegionID, .BMDShipToID
    Err.Raise Err.Number, "[fBMDShipTo_AddNewBMDShipTo]" & Err.Source, Err.Description
    ReportError Err, "[fBMDShipTo_Form_Load]"
    ReportError Err, "[fBMDShipTo_Form_Resize]"
Dim lBMDShipToID As Long
    lBMDShipToID = grdShipTo.RowData(row)
            gDBAccess.AssociateBMDShipToRetailer lBMDShipToID, .RetailerRegionID
    ReportError Err, "[fBMDShipTo_grdShipTo_CellButtonClick]"
Dim bmdImport As clsBMDShipToImport
    Set bmdImport = New clsBMDShipToImport
    bmdImport.Import Me, pbarMgr
    If bmdImport.HasExceptions Then
        Load fBMDShipToExceptions
        Set fBMDShipToExceptions.BMDShipToImport = bmdImport
        fBMDShipToExceptions.Show vbModal
    ReportError Err, "[fBMDShipTo_mnuToolsImport_Click]"
' fill the grid with BMDShipTo records.
    Set rsShipTos = gDBAccess.GetAllBMDShipTo
                       !RetailerRegionDesc, !RetailerRegionID, !BMDShipToID
    Err.Raise Err.Number, "[fBMDShipTo_PopulateGrid]" & Err.Source, Err.Description
                       BMDShipToID As Long)
    grdShipTo.RowData(grdShipTo.Rows - 1) = BMDShipToID
    Err.Raise Err.Number, "[fBMDShipTo.AddElement]" & Err.Source, Err.Description

---------- BMDSHIPTOADD.FRM
Begin VB.Form fBMDShipToAdd 
   Icon            =   "BMDShipToAdd.frx":0000
Attribute VB_Name = "fBMDShipToAdd"
Public Sub Populate(bsr As clsBMDSales)
    Err.Raise Err.Number, "[fBMDShipToAdd_Populate]" & Err.Source, Err.Description
    ReportError Err, "[fBMDShipToAdd_cmdChooseRetailer_Click]"
Dim bmdShipTo As clsBMDShipTo
        Set bmdShipTo = gDBAccess.CreateBMDShipTo
        With bmdShipTo
            frmCaller.AddNewBMDShipTo bmdShipTo, txtRetailerRegionDesc.Text
    ReportError Err, "[fBMDShipToAdd_cmdOK_Click]"
    ReportError Err, "[fBMDShipToAdd_Form_Load]"
    Err.Raise Err.Number, "[fBMDShipToAdd_ValidateForm]" & Err.Source, Err.Description

---------- BMDSHIPTOCHOOSE.FRM
Begin VB.Form fBMDShipToChoose 
   Icon            =   "BMDShipToChoose.frx":0000
      FormatString    =   $"BMDShipToChoose.frx":08CA
Attribute VB_Name = "fBMDShipToChoose"
Private Const COL_BMDSHIPTOID As Integer = 9
Private rsBMDShipTo As Recordset
Public Property Get BMDShipToID() As Long
' if a BMDShipTo record has been selected, return that.  otherwise return -1.
            BMDShipToID = .Cell(flexcpValue, .SelectedRow(0), COL_BMDSHIPTOID)
            BMDShipToID = -1
    Err.Raise Err.Number, "[fBMDShipToChoose_BMDShipToID]" & Err.Source, Err.Description
    Err.Raise Err.Number, "[fBMDShipToChoose_ShipToName]" & Err.Source, Err.Description
    Err.Raise Err.Number, "[fBMDShipToChoose_ShipToLocation]" & Err.Source, Err.Description
Public Function LoadData(BMDShipToID As Long)
' if BMDShipToID exists select that row.
    lRow = FindBMDShipToID(BMDShipToID)
    Err.Raise Err.Number, "[fBMDShipToChoose_LoadData]" & Err.Source, Err.Description
    Err.Raise Err.Number, "[fBMDShipToChoose_cmdNoSelection_Click]" & Err.Source, Err.Description
    ReportError Err, "[fBMDShipToChoose.Form_Load]"
    Set rsBMDShipTo = gDBAccess.GetAllBMDShipTo_Chooser
    Set grdShipTo.DataSource = rsBMDShipTo
    Err.Raise Err.Number, "[fBMDShipToChoose_PopulateGrid]" & Err.Source, Err.Description
Private Function FindBMDShipToID(BMDShipToID As Long) As Long
' find the row that contains this BMDShipToID, or return -1 if not found.
            If .Cell(flexcpValue, lRow, COL_BMDSHIPTOID) = BMDShipToID Then
                FindBMDShipToID = lRow
    FindBMDShipToID = -1
    Err.Raise Err.Number, "[fBMDShipToChoose_FindBMDShipToID]" & Err.Source, Err.Description
    ReportError Err, "[fBMDShipToChoose_Form_Resize]"
    ' hide BMDShipToID and RetailerRegionID columns
        .ColHidden(GridFindCol(grdShipTo, 0, "BMDShipToID")) = True
    ReportError Err, "[fBMDShipToChoose_grdShipTo_AfterDataRefresh]"
    Err.Raise Err.Number, "[fBMDShipToChoose_grdShipTo_AfterSelChange]" & Err.Source, Err.Description
Dim lBMDShipToID As Long
    lBMDShipToID = grdShipTo.Cell(flexcpValue, row, COL_BMDSHIPTOID)
            gDBAccess.AssociateBMDShipToRetailer lBMDShipToID, .RetailerRegionID
    ReportError Err, "[fBMDShipToChoose_grdShipTo_CellButtonClick]"

---------- BMDSHIPTOEXCEPTIONS.FRM
Begin VB.Form fBMDShipToExceptions 
   Icon            =   "BMDShipToExceptions.frx":0000
      FormatString    =   $"BMDShipToExceptions.frx":08CA
Attribute VB_Name = "fBMDShipToExceptions"
Private BMDShipToGenerator As clsBMDShipToImport
Private colBMDShipTos As Collection
Public Property Set BMDShipToImport(o As clsBMDShipToImport)
    Set BMDShipToGenerator = o
    Set colBMDShipTos = BMDShipToGenerator.BMDShipToCollection
    ReportError Err, "[fBMDShipToExceptions_Form_Load]"
Dim oExcept As IBMDException
    Set colExceptions = BMDShipToGenerator.Exceptions
            Case BMDEXCEPTION_CRITICAL
            Case BMDEXCEPTION_MATCHROOT
            Case BMDEXCEPTION_MATCHSTORE
            Case BMDEXCEPTION_VALIDATION
    Err.Raise Err.Number, "[fBMDShipToExceptions_PopulateGrid]" & Err.Source, Err.Description
Private Sub AddException_Critical(critExcept As clsBMDExceptionCritical)
    Err.Raise Err.Number, "[fBMDShipToExceptions_AddException_Critical]" & Err.Source, Err.Description
Private Sub AddException_MatchRoot(matchExcept As clsBMDExceptionMatchRoot)
               ShipToID:=.bmdShipTo.ShipToID & vbNullString, _
               RetailerName:=.bmdShipTo.RetailerName & vbNullString, _
               StoreLocation:=.bmdShipTo.StoreLocation & vbNullString, _
               StoreNo:=.bmdShipTo.StoreNo & vbNullString, _
               State:=.bmdShipTo.State & vbNullString, _
               BMDShipToID:=.bmdShipTo.BMDShipToID & vbNullString
    Err.Raise Err.Number, "[fBMDShipToExceptions_AddException_MatchRoot]" & Err.Source, Err.Description
Private Sub AddException_MatchStore(matchExcept As clsBMDExceptionMatchStore)
               ShipToID:=.bmdShipTo.ShipToID & vbNullString, _
               RetailerName:=.bmdShipTo.RetailerName & vbNullString, _
               StoreLocation:=.bmdShipTo.StoreLocation & vbNullString, _
               StoreNo:=.bmdShipTo.StoreNo & vbNullString, _
               State:=.bmdShipTo.State & vbNullString, _
               BMDShipToID:=.bmdShipTo.BMDShipToID & vbNullString
    Err.Raise Err.Number, "[fBMDShipToExceptions_AddException_MatchStore]" & Err.Source, Err.Description
Private Sub AddException_Validate(validateExcept As clsBMDExceptionValidate)
    Err.Raise Err.Number, "[fBMDShipToExceptions_AddException_Validate]" & Err.Source, Err.Description
                   Optional ByVal BMDShipToID As Long = 0)
        .RowData(.Rows - 1) = BMDShipToID
    Err.Raise Err.Number, "[fBMDShipToExceptions.AddRow]" & Err.Source, Err.Description
Dim lBMDShipToID As Long
Dim bmdShipTo As clsBMDShipTo
    lBMDShipToID = grdExceptions.RowData(row)
    If lBMDShipToID > 0 Then
                ' update this bmdShipTo object.
                Set bmdShipTo = colBMDShipTos(FW_COLLECTION_KEY & grdExceptions.RowData(row))
                    bmdShipTo.RetailerRegionID = .RetailerRegionID
                    bmdShipTo.RetailerRegionID = Null
                bmdShipTo.UpdateRow
    ReportError Err, "[fBMDShipToExceptions_grdExceptions_CellButtonClick]"

---------- DISTRORETAIL.FRM
    '2008-Mar-28: Added True to exclude the sheet for the BMD locations.

---------- DIXIESALESENTRY.FRM
' Grid location.  This matches BMD but we'll hide

---------- DIXIESALESEXCEPTIONS.FRM
Dim bmdProduct As clsDixieProduct
    Set bmdProduct = gDBAccess.GetDixieProduct(matchExcept.bmdSales.MajorMinorID)
    If Not bmdProduct Is Nothing Then
        If Not IsNull(bmdProduct.ProductTypeID) Then
            Set prod = gDBAccess.GetProduct(bmdProduct.ProductTypeID)
               .bmdSales.SalesAmt & vbNullString, _
               .bmdSales.ShiptoName & vbNullString, _
               .bmdSales.MajorMinorID & vbNullString, _
               .bmdSales.DixieProductDesc & vbNullString, _
               .bmdSales.DixieShipToID & vbNullString, _
               .bmdSales.DixieSalesID & vbNullString
               .bmdSales.SalesAmt & vbNullString, _
               .bmdSales.ShiptoName & vbNullString, _
               .bmdSales.MajorMinorID & vbNullString, _
               .bmdSales.DixieProductDesc & vbNullString, _
               .bmdSales.DixieShipToID & vbNullString, _
               .bmdSales.DixieSalesID & vbNullString
Dim bmdSales As clsDixieSales
                Set bmdSales = colDixieSales(FW_COLLECTION_KEY & grdExceptions.RowData(row))
                bmdSales.DixieShipToID = .DixieShipToID
                bmdSales.UpdateRow

---------- DIXIESHIPTOADD.FRM
Dim bmdShipTo As clsDixieShipTo
        Set bmdShipTo = gDBAccess.CreateDixieShipTo
        With bmdShipTo
            frmCaller.AddNewDixieShipTo bmdShipTo, txtRetailerRegionDesc.Text

---------- MAIN.FRM
   Begin VB.CommandButton cmdBMD 
      ToolTipText     =   "View and Edit information about BMD import data"
   Begin VB.Label lblBMD 
      Caption         =   "BMD Import"
      ToolTipText     =   "View and Edit information about BMD import data"
Private Sub cmdBMD_Click()
    fBMDSalesEntry.Show
    ReportError Err, "[fMain_cmdBMD_Click]"
    ReportError Err, "[fMain_cmdBMD_Click]"
        cmdBMD.Enabled = bWritePermission
        lblBMD.Enabled = bWritePermission

---------- REPORTS.FRM
      Begin VB.CheckBox chkBMDOnly 
         Caption         =   "BMD Only"
         Caption         =   "BMD Batch Detail"
         Caption         =   "Retail BMD Sales - By Product"
         Caption         =   "Retailer Sales - BMD Only"
         Caption         =   "Retailer Sales Summary - BMD"
      Caption         =   "BMD Batch:"
    ctBMDOnly = 32&
    optRetailSalesSummaryBMD                    '8
    optRetailSalesBMD                           '2
    optBMDSalesByProduct                        '3
    '2012-Dec-18: Add BMD only option.
    chkBMDOnly.Enabled = (chkBMDOnly.Visible And chkSummary.Value = 1)
    If Not chkBMDOnly.Enabled Then chkBMDOnly.Value = 0
    Case optRetailSales, optRetailSalesBMD, optRetailSalesSummaryBMD
    Case optBMDSalesByProduct, optBuilderSalesDetail, _
            MsgBox "Please select a BMD Import Batch."
            '2012-Dec-18: Add BMD only option.
            'chkBMDOnly.Value = 0
        Case optRetailSalesBMD, optRetailSalesSummaryBMD  ' Retailer Sales Detail Report (1) and BMD Only Detail (2)
            If nOptionIndex = optRetailSalesSummaryBMD Then
            chkBMDOnly.Value = 1
        Case optBMDSalesByProduct ' Retailer Sales Detail - BMD By Product
            chkBMDOnly.Value = 1
            Set oRpt = New Report_BMDBatch
            Set oRpt = New Report_BMDBatch
    LoadBMDBatchCombo IDICboBatch
    Case optRetailSales, optRetailSalesSummaryBMD
    Case optRetailSalesBMD, optBMDSalesByProduct, _
            chkExecSummary.Visible = True And Option1(optRetailSalesSummaryBMD) = 0 '(Option1(optRetailSales) = 0 Or ActiveOption <> optRetailSales)
            '2012-Dec-18: Add BMD only option.
            chkBMDOnly.Visible = (Option1(optRetailSales).Value <> 0)
            chkBMDOnly.Enabled = (chkSummary.Value = 1)
        Case ctBMDOnly
        Or Option2(optAccrual).Value <> 0 Or Option1(optRetailSalesSummaryBMD) = True Then bHideSort = True

